#!/usr/bin/env python
# encoding: utf-8
'''
@author: Excelsiorly
@license: (C) Copyright 2021, All Rights Reserved.
@contact: excelsiorly@qq.com
@file: 0009.py
@time: 2021/9/11 16:35
@desc:
'''
class Solution:
    def findIntegers(self, n: int) -> int:
        count = 0
        if n==0:
            return 1
        if n==1:
            return 2
        for i in range(n+1):
            prev = 2
            while not i == 0:
                bit = i%2
                i = i // 2
                if bit==1 and prev == 1:
                    count += 1
                    break
                else:
                    prev = bit

        return n + 1 - count

if __name__ == '__main__':
    s = Solution()
    n = 7
    r = s.findIntegers(n)
    print(r)